package com.chuangsi.project.admin.controller.app;


import com.chuangsi.framework.web.domain.ResultObject;
import com.chuangsi.project.admin.dto.app.esign.*;
import com.chuangsi.project.admin.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author wangshengming
 * @date 2023/4/4
 */
@Api(tags = "APP-签署流程")
@RestController
@RequestMapping("/userApi/signApp")
public class AppletsSignController {

    @Autowired
    private OrderService orderService;

    //上传文件-开始签署-获取签署页面链接
    @ApiOperation(value = "开始签署流程", notes = "王圣铭")
    @PostMapping("/signTurned")
    public ResultObject<ResESignGetFileUpDto> signTurned(@RequestBody @Valid ReqESignGetFileUpDto req) {
        ResESignGetFileUpDto res = orderService.signTurned(req);
        return ResultObject.ok("操作成功").setData(res);
    }

    @ApiOperation(value = "查询签署流程情况")
    @PostMapping("/getSignDetail")
    public ResultObject<ResESignGetSignFlowDetailDto> getSignDetail(@RequestBody @Valid ReqESignGetSignFlowDetailDto req){
        ResESignGetSignFlowDetailDto res = orderService.getSignDetail(req);
        return ResultObject.ok("查询成功").setData(res);
    }

    @ApiOperation(value = "下载签署文件",notes = "王圣铭")
    @PostMapping("/download")
    public ResultObject<ResESignDownloadDto> download(@RequestBody @Valid ReqESignDownloadDto req){
        ResESignDownloadDto res = orderService.download(req);
        return ResultObject.ok("获取地址成功").setData(res);
    }


}

